﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<QuanLyNhaThuoc.Models.PagingModel>" %>
<%
    if ((bool)ViewData["Inactive"]) {
        if (ViewData["Text"].ToString() == "Trước") {
            Response.Write("<li class='next disabled'>");
        } else if (ViewData["Text"].ToString() == "Sau") {
            Response.Write("<li class='prev disabled'>");
        } else {
            Response.Write("<li>");
        }

        Response.Write(string.Format("<span class=\"{0}\">{1}</span>", "pagerButtonDisabled", ViewData["Text"]));
        Response.Write("</li>");
    } else {

        if ((bool)ViewData["Selected"])
            Response.Write("<li class='active'>");
        else
            Response.Write("<li>");


        var routeData = new RouteValueDictionary { { "page", ViewData["PageIndex"].ToString() }, { "pageSize", Model.PageSize } };

        // Add querystring parameters to the route collection
        QuanLyNhaThuoc.HelperClass.RouteValueDictionaryExtensions.AddQueryStringParameters(routeData);

        var htmlAttributes = new Dictionary<string, object>();
        if ((bool)ViewData["Selected"])
            htmlAttributes.Add("class", "pagerButtonCurrentPage");
        else
            htmlAttributes.Add("class", "pagerButton");

        Response.Write(
            Html.ActionLink(
                    ViewData["Text"].ToString(),                                    // Link Text
                    Html.ViewContext.RouteData.Values["action"].ToString(),         // Action
                    Html.ViewContext.RouteData.Values["controller"].ToString(),     // Controller
                    routeData,                                                      // Route data
                    htmlAttributes                                                  // HTML attributes to apply to hyperlink
                ).ToHtmlString()
        );

        Response.Write("</li>");
    }
%>